package com.ragdollcat.thirdaicodegenerate.service;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.ragdollcat.thirdaicodegenerate.model.dto.chathistory.ChatHistoryQueryRequest;
import com.ragdollcat.thirdaicodegenerate.model.entity.ChatHistory;
import com.ragdollcat.thirdaicodegenerate.model.entity.User;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;

import java.time.LocalDateTime;

/**
 * 对话历史 服务层。
 *
 * @author Administrator
 */
public interface ChatHistoryService extends IService<ChatHistory> {

    /**
     * 保存对话历史记录
     *
     * @return
     */
    boolean saveChatHistory(String text,Long appId,Long userId,String messageType);

    /**
     * 分页查询对话历史
     * @param appId
     * @param pageSize
     * @param localDateTime
     * @param user
     * @return
     */
    Page<ChatHistory> getChatHistoryByPage(Long appId, int pageSize, LocalDateTime localDateTime, User user);

    /**
     * 分页查询对话历史(管理员)
     * @param chatHistoryQueryRequest
     * @return
     */
    Page<ChatHistory> getChatHistoryByPage4Admin(ChatHistoryQueryRequest chatHistoryQueryRequest);

    /**
     * 从数据库加载对话记忆到redis中
     * @param appId
     * @param messageWindowChatMemory
     */
    void ChatHisD2Memory(long appId, MessageWindowChatMemory messageWindowChatMemory, int count);
}
